<?php
	include "./addons/AdManager/config/config.php";
	include "./addons/AdManager/expand/common.html";
?>


<style type="text/css">
#globalAd {
	max-width: 400px;
	flex-basis: 100%;
	margin: 0 auto;
	background: #FFF;
	border-radius: 10px;
	box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
	-webkit-box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
 overflow:hidden;
 position:fixed;
 display:none;
 margin:0 auto;
 z-index:10001
}
.Adslayer{
	width:100%; 
	height:100%;  
	position:fixed; 
	top:0px;
	left:0px;filter:alpha(opacity=50);
	opacity:0.5;
	background:#000;
	z-index:1000;
	display:none
}
#globalAd #hero-img {
	width: 100%;
	height: 100px;
	background: #007bff;
}
#globalAd #profile-img {
	width: 80px;
	height: 80px;
	margin: -80px auto 0 auto;
	border: 6px solid #FFF;
	border-radius: 50%;
	box-shadow: 0 0 5px rgba(90, 90, 90, 0.3);
}
#globalAd #profile-img img {
	width: 100%;
	background: #FFF;
	border-radius: 50%;
}
#globalAd #content {
	text-align: center;
	width: 320px;
	margin: 0 auto;
	padding: 0 0 0 0;
}
</style>
<!--全局广告开始-->
<div class="AdsAdslayer"></div>
<div id="globalAd">
	<div id='hero-img' style="background-image: url(https://s2.ax1x.com/2020/03/11/8EmODs.jpg);background-repeat: no-repeat;background-size: 100% 100%;-moz-background-size: 100% 100%;">
	</div>
	<div id='profile-img'>
		<img src='https://s2.ax1x.com/2020/03/11/8EnC2F.gif'/>
	</div>
	<div id='content'>
	    <div class="c1">
			<?php
				if ($lywq['AdManager']['pupop']['type'] == 1) { 
					echo '<p>' .$lywq['AdManager']['pupop']['code1']. '</p>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 2) {
					echo '<a href="' .$lywq['AdManager']['pupop']['url1']. '" >';
					echo '<img src="' .$lywq['AdManager']['pupop']['image1']. '" width="100%" />';
					echo '</a>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 3) {
					if ($_COOKIE["Zterminal"]=='true') {
						echo '<p>' .$lywq['AdManager']['pupop']['Zcode1']. '</p>';
					}else{
						echo '<p>' .$lywq['AdManager']['pupop']['Qcode1']. '</p>';
					}
				}
			?>
			<?php
				if ($lywq['AdManager']['closepupop']['type'] == 1) { 
					echo '<input type="button" value="' .$lywq['AdManager']['closepupop']['button']. '" onClick="closeGlobalAd()">';
				}
				if ($lywq['AdManager']['closepupop']['type'] == 2) {
					echo '<a href="javascript:void(0);" onClick="closeGlobalAd()">';
					echo '<img src="' .$lywq['AdManager']['closepupop']['image']. '" width="100%" />';
					echo '</a>';
				}
			?>
	    </div>
	    <div class="c1" hidden="">
			<?php
				if ($lywq['AdManager']['pupop']['type'] == 1) { 
					echo '<p>' .$lywq['AdManager']['pupop']['code2']. '</p>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 2) {
					echo '<a href="' .$lywq['AdManager']['pupop']['url2']. '" >';
					echo '<img src="' .$lywq['AdManager']['pupop']['image2']. '" width="100%" />';
					echo '</a>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 3) {
					if ($_COOKIE["Zterminal"]=='true') {
						echo '<p>' .$lywq['AdManager']['pupop']['Zcode2']. '</p>';
					}else{
						echo '<p>' .$lywq['AdManager']['pupop']['Qcode2']. '</p>';
					}
				}
			?>
			<?php
				if ($lywq['AdManager']['closepupop']['type'] == 1) { 
					echo '<input type="button" value="' .$lywq['AdManager']['closepupop']['button']. '" onClick="closeGlobalAd()">';
				}
				if ($lywq['AdManager']['closepupop']['type'] == 2) {
					echo '<a href="javascript:void(0);" onClick="closeGlobalAd()">';
					echo '<img src="' .$lywq['AdManager']['closepupop']['image']. '" width="100%" />';
					echo '</a>';
				}
			?>
	    </div>
	    <div class="c1" hidden="">
			<?php
				if ($lywq['AdManager']['pupop']['type'] == 1) { 
					echo '<p>' .$lywq['AdManager']['pupop']['code3']. '</p>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 2) {
					echo '<a href="' .$lywq['AdManager']['pupop']['url3']. '" >';
					echo '<img src="' .$lywq['AdManager']['pupop']['image3']. '" width="100%" />';
					echo '</a>';
				}
				if ($lywq['AdManager']['pupop']['type'] == 3) {
					if ($_COOKIE["Zterminal"]=='true') {
						echo '<p>' .$lywq['AdManager']['pupop']['Zcode3']. '</p>';
					}else{
						echo '<p>' .$lywq['AdManager']['pupop']['Qcode3']. '</p>';
					}
				}
			?>
			<?php
				if ($lywq['AdManager']['closepupop']['type'] == 1) { 
					echo '<input type="button" value="' .$lywq['AdManager']['closepupop']['button']. '" onClick="closeGlobalAd()">';
				}
				if ($lywq['AdManager']['closepupop']['type'] == 2) {
					echo '<a href="javascript:void(0);" onClick="closeGlobalAd()">';
					echo '<img src="' .$lywq['AdManager']['closepupop']['image']. '" width="100%" />';
					echo '</a>';
				}
			?>
	    </div>
	</div>
</div>


<script type="text/javascript">
if('<?php echo $lywq['AdManager']['interval']['type'];?>'!=0){
	document.addEventListener('visibilitychange',function(){
		var isHidden = document.hidden;
		if(isHidden){
			closeGlobalAd();
		} else {
			closeGlobalAd();
		}
	});
}

if('<?php echo $lywq['AdManager']['pupop']['carousel'];?>'==1){
	$(function() {
	    var i = 0;
	    $(".c1").eq(0).show().siblings().hide();
	    setInterval(function() {
	        i++;
	        if (i == 3) {
	            i = 0;
	        }
	        $(".c1").eq(i).show().siblings().hide();
	    }, 2000);
	    
	});
}else{
	$(".c1").eq(0).show();
}

function lywq_openAdManagerpupop(){
    var erdangjiadeH = $(window).height();
    var erdangjiadeW = $(window).width();
    $(".AdsAdslayer").show();
    $("#globalAd").css({'top': erdangjiadeH/2-$("#globalAd").height()/2,'left': erdangjiadeW/2-$("#globalAd").width()/2 });
    $("#globalAd").show();
}

function closeGlobalAd(){
    $('#globalAd').hide();
    $('.AdsAdslayer').hide();

}

setCookie("Zterminal",false,1);
if (browser.versions.mobile) {
        if(browser.versions.android && !browser.versions.bsl){
            if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('android')!==-1){
				AdManagercookieController();
				if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('android')!==-1){
				    if(checkCookie("Zterminal")){
				        setCookie("Zterminal",true,1);
				    }
				}
            }
    	}
        if (browser.versions.ios) {
            if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('ios')!==-1){
				AdManagercookieController();
				if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('ios')!==-1){
				    if(checkCookie("Zterminal")){
				        setCookie("Zterminal",true,1);
				    }
				}
            }
        }
        if (browser.versions.weixin) {
            if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('weixin')!==-1){
            	AdManagercookieController();
				if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('weixin')!==-1){
				    if(checkCookie("Zterminal")){
				        setCookie("Zterminal",true,1);
				    }
				}
            }
        }
        if (browser.versions.qq) {
            if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('qq')!==-1){
            	AdManagercookieController();
				if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('qq')!==-1){
				    if(checkCookie("Zterminal")){
				        setCookie("Zterminal",true,1);
				    }
				}
            }
        }
        if (browser.versions.bsl) {
            if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('bsl')!==-1){
            	AdManagercookieController();
				if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('bsl')!==-1){
				    if(checkCookie("Zterminal")){
				        setCookie("Zterminal",true,1);
				    }
				}
            }
        }
}else{
    if('<?php echo $lywq['AdManager']['terminal'];?>'.indexOf('pc')!==-1){
    	AdManagercookieController();
		if('<?php echo $lywq['AdManager']['Zterminal'];?>'.indexOf('pc')!==-1){
			if(checkCookie("Zterminal")){
				setCookie("Zterminal",true,1);
			}
		}
    }
}

function AdManagercookieController(){
	if('<?php echo $lywq['AdManager']['status'];?>'==1 && '<?php echo $lywq['AdManager']['pupop']['status'];?>'==1){
		if('<?php echo $lywq['AdManager']['interval']['type'];?>'==0){
	    	lywq_openAdManagerpupop();
		}
		if('<?php echo $lywq['AdManager']['interval']['type'];?>'==1){
	    	var value = checkCookie('lywq_AdManager_cookie');
	    	if(value==false){
	    		lywq_openAdManagerpupop();
	    		
	    		setCookie('lywq_AdManager_cookie','time','<?php echo $lywq['AdManager']['interval']['time'];?>');
	    	}
		}
		if('<?php echo $lywq['AdManager']['interval']['type'];?>'==2){
	    	var value = checkCookie('lywq_AdManager_cookie');
	    	if(value==false){
	    		lywq_openAdManagerpupop();
	    		
	    		var number = '<?php echo $lywq['AdManager']['interval']['number'];?>';
	    		var expire = (24*60)/number ;
	    		setCookie('lywq_AdManager_cookie','number',expire);
	    	}
		}
	} 

}

</script>